//
//  CourseService.m
//  WisdomStar
//
//  Created by 谭飞 on 2018/11/12.
//  Copyright © 2018年 zhangliwen. All rights reserved.
//

#import "CourseService.h"

#import "CourseFilterInfoAPI.h"
#import "AddCourseAPI.h"
#import "CourseCateAPI.h"

@implementation CourseService


/**
 获取课程类别

 @param result call back
 */
+ (void)fetchCourseCateWithResult:(void (^)(id _Nonnull))result {
    CourseCateAPI *api = [[CourseCateAPI alloc] init];
    [api startWithCompletionBlockWithSuccess:^(__kindof YTKBaseRequest * _Nonnull request) {
        result(request.responseObject);
    } failure:^(__kindof YTKBaseRequest * _Nonnull request) {
        result(request.responseObject);
    }];
}

/**
 获取添加课程信息

 @param result call back
 */
+ (void)fetchAddCourseInfoWithResult:(void (^)(id _Nonnull))result {
    CourseFilterInfoAPI *api = [[CourseFilterInfoAPI alloc] init];
    [api startWithCompletionBlockWithSuccess:^(__kindof YTKBaseRequest * _Nonnull request) {
        result(request.responseObject);
    } failure:^(__kindof YTKBaseRequest * _Nonnull request) {
        result(request.responseObject);
    }];
}


/**
 发布课程

 @param params params
 @param complete call back
 */
+ (void)addCourseWithParams:(NSMutableDictionary *)params completion:(void (^)(BOOL, id _Nonnull))complete {
    AddCourseAPI *api = [[AddCourseAPI alloc] init];
    api.outerParameters = params;
    [api startWithCompletionBlockWithSuccess:^(__kindof YTKBaseRequest * _Nonnull request) {
        complete(true, request.responseObject);
    } failure:^(__kindof YTKBaseRequest * _Nonnull request) {
        IOAResponse *response = [IOAResponse responseWithRequest:request];
        [SVProgressHUD showError:response.responseMessage];
        complete(false, request.responseObject);
    }];
}

@end
